home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / A-B / add images.cpt / initclut.c < prev    next >
Text File  |  1989-06-22  |  2KB  |  123 lines

  1.  
  2. /*
  3.     initclut.c
  4.  
  5.     5/1/89
  6.     c. keith ray
  7.  
  8.     procedure to initialize color lookup table
  9.     based on code from IMAGE
  10. */
  11.  
  12. #include "initclut.h"
  13. #include "about_alert.h"
  14. #include <IM1_5Protos.h>
  15.  
  16. #define      NIL    0
  17.  
  18. extern WindowPtr Result_Window;    /* Window pointer */
  19. extern WindowPtr proton_Window;    /* Window pointer */
  20. extern WindowPtr flourine_Window;
  21.  
  22. PaletteHandle mypalette;
  23. RGBColor BlackRGB, whiteRGB, grayRGB;
  24.  
  25. void Init_gray_clut()
  26.     short jk, col;
  27.     /* 
  28.         create a single Palette that will be shared with all my windows and hopefully,
  29.         the offscreen pixmap as well.
  30.     */
  31.     unsigned short i, j;
  32.  
  33.     mypalette = NewPalette(all_my_colors, 0L, pmTolerant, 0); 
  34.     /* requires exact matches to specified colors */
  35.     
  36.     col = maxintensity;
  37.     for ( jk = 0; jk < all_my_colors; jk++ )
  38.     {
  39.         grayRGB.red = col;
  40.         grayRGB.blue = col;
  41.         grayRGB.green = col;
  42.         SetEntryColor(mypalette, jk, &grayRGB);
  43.         col -= (maxintensity / all_my_colors);
  44.     }
  45.     BlackRGB.red = 0;
  46.     BlackRGB.blue = 0;
  47.     BlackRGB.green = 0;
  48.  
  49.     whiteRGB.red = maxintensity;
  50.     whiteRGB.blue = maxintensity;
  51.     whiteRGB.green = maxintensity;
  52.  
  53.     grayRGB.red = maxintensity / 2;
  54.     grayRGB.blue = maxintensity / 2;
  55.     grayRGB.green = maxintensity / 2;
  56. }
  57.  
  58.  
  59. void init_clut_flourine() /* source 1 */
  60. {    
  61.     short i;
  62.     
  63.     SetPalette( flourine_Window, mypalette, TRUE);
  64.     RGBBackColor(&whiteRGB);
  65.     RGBForeColor(&BlackRGB); /* copybits usually expect black fore and white back */
  66.     OpColor(&grayRGB);
  67.     
  68.     ActivatePalette( flourine_Window );
  69.  
  70. }
  71.  
  72. void init_clut_proton() /* source 2 */
  73. {
  74.     short i;
  75.     
  76.     SetPalette( proton_Window, mypalette, TRUE);
  77.     RGBBackColor(&whiteRGB);
  78.     RGBForeColor(&BlackRGB); /* copybits usually expect black fore and white back */
  79.     OpColor(&grayRGB);
  80.     ActivatePalette( proton_Window );
  81.  
  82. }
  83.  
  84. void myForeColor( r, g, b )
  85.     unsigned short r, b, g;
  86. /* makes it easier to do RGBForeColor */
  87. {
  88.     RGBColor mycolor;
  89.  
  90.     mycolor.red = r;
  91.     mycolor.green = g;
  92.     mycolor.blue = b;
  93.     RGBForeColor( &mycolor );
  94. }
  95.  
  96. void myBackColor( r, g, b )
  97.     unsigned short r, b, g;
  98. /* makes it easier to do RGBBackColor */
  99. {
  100.     RGBColor mycolor;
  101.  
  102.     mycolor.red = r;
  103.     mycolor.green = g;
  104.     mycolor.blue = b;
  105.     RGBBackColor( &mycolor );
  106. }
  107.  
  108. void init_clut_result(  )
  109. {
  110.     short i;
  111.     
  112.     SetPalette( Result_Window, mypalette, TRUE);
  113.     RGBBackColor(&whiteRGB);
  114.     RGBForeColor(&BlackRGB); /* copybits usually expect black fore and white back */
  115.     OpColor(&grayRGB);
  116.     ActivatePalette( Result_Window );
  117.     for ( i = 0; i < all_my_colors; i++ )
  118.     {
  119.         ProtectEntry(i, TRUE);
  120.     }
  121. }
  122.